@extends('admin.main_table')
@section('title', '管理员管理')

@section('css')
    <link href="{{ asset('/static/css/admin/admin.css') }}" rel="stylesheet">
    <style>
        .pagination-detail{
            margin-left:20px;
        }
        .pagination{
            margin-right:20px;
        }
    </style>
@endsection

@section('content')
    <ol class="breadcrumb" style="margin:0px;">
        <li><a href="/testManage">测试</a></li>
        <li class="active">测试结果</li>
    </ol>
    <div class="col-md-12 main_body">
        <div style="margin-bottom:10px;">
            <button class="btn btn-default" type="button" id="add"><img src="{{ asset('/static/img/新增.png') }}" style="width:18px;height:18px;"/>&nbsp;新增</button>
            <button class="btn btn-default" type="button" id="delete"><img src="{{ asset('/static/img/删除.png') }}" style="width:18px;height:18px;"/>&nbsp;删除</button>
            <button class="btn btn-default" type="button" id="change"><img src="{{ asset('/static/img/修改.png') }}" style="width:18px;height:18px;"/>&nbsp;修改</button>
        </div>
        <div style="display:none;" id="test_id">{{ $id }}</div>
        <table data-toggle="table" id="test_table"></table>
    </div>
@endsection

@section('script')
    <script>
        function initTable(id){
            var $table = $('#test_table');
            $table.bootstrapTable({
                pagination: true, //分页
                url: '/admin/getAllTestResult?id='+id,
                pageList:[15,30,50],
                columns: [{
                    checkbox: true
                },{
                    field: 'id',
                    title: '测试结果id'
                }, {
                    field: 'Number',
                    title: 'id',
                    formatter: function (value, row, index) {
                        return index+1;
                    }
                }, {
                    field: 'testId',
                    title: '测试id'
                }, {
                    field: 'result',
                    title: '结果'
                }]
            });
            $table.bootstrapTable('hideColumn', 'id');
        }
        var test_id=$("#test_id").text();
        //alert(test_id);
        initTable(test_id);

        $("#add").click(function(){
            window.location="/addTestResult?id="+test_id;
        });
        $('#delete').click(function () {
            var row=$('#test_table').bootstrapTable('getSelections');
            $.post('/deleteTestResult',{'row':row},function(data){
                window.location="/admin/testResultManage?id="+test_id;
            })
        });
        $("#change").click(function(){
            var row=$('#test_table').bootstrapTable('getSelections');
            var id=row[0].id;
            //alert(id)
            //console.log(id);
            window.location="/updateTestResult?id="+id;
        });
    </script>

@endsection